<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GSocketAddress</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GIO 参考手册">
<link rel="up" href="networking.html" title="Lowlevel network support">
<link rel="prev" href="gio-GInetAddress.html" title="GInetAddress">
<link rel="next" href="gio-GInetSocketAddress.html" title="GInetSocketAddress">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gio-GInetAddress.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="networking.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GIO 参考手册</th>
<td><a accesskey="n" href="gio-GInetSocketAddress.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gio-GSocketAddress.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gio-GSocketAddress.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gio-GSocketAddress"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gio-GSocketAddress.top_of_page"></a>GSocketAddress</span></h2>
<p>GSocketAddress — Abstract base class representing endpoints for
socket communication</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gio-GSocketAddress.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">                    <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress">GSocketAddress</a>;
enum                <a class="link" href="gio-GSocketAddress.html#GSocketFamily" title="enum GSocketFamily">GSocketFamily</a>;
<a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> *       <a class="link" href="gio-GSocketAddress.html#g-socket-address-new-from-native" title="g_socket_address_new_from_native ()">g_socket_address_new_from_native</a> (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> native</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> len</code></em>);
<a class="link" href="gio-GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a>       <a class="link" href="gio-GSocketAddress.html#g-socket-address-get-family" title="g_socket_address_get_family ()">g_socket_address_get_family</a>         (<em class="parameter"><code><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gio-GSocketAddress.html#g-socket-address-to-native" title="g_socket_address_to_native ()">g_socket_address_to_native</a>          (<em class="parameter"><code><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> dest</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> destlen</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<a href="../glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a>              <a class="link" href="gio-GSocketAddress.html#g-socket-address-get-native-size" title="g_socket_address_get_native_size ()">g_socket_address_get_native_size</a>    (<em class="parameter"><code><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gio-GSocketAddress.description"></a><h2>Description</h2>
<p>
<a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> is the equivalent of <span class="type">struct sockaddr</span>
in the BSD sockets API. This is an abstract class; use
<a class="link" href="gio-GInetSocketAddress.html#GInetSocketAddress" title="GInetSocketAddress"><span class="type">GInetSocketAddress</span></a> for internet sockets, or <a class="link" href="gio-GUnixSocketAddress.html#GUnixSocketAddress" title="struct GUnixSocketAddress"><span class="type">GUnixSocketAddress</span></a>
for UNIX domain sockets.
</p>
</div>
<div class="refsect1">
<a name="gio-GSocketAddress.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GSocketAddress"></a><h3>GSocketAddress</h3>
<pre class="programlisting">typedef struct {
  GObject parent_instance;
} GSocketAddress;
</pre>
<p>
A socket endpoint address, corresponding to <span class="type">struct sockaddr</span>
or one of its subtypes.
</p>
</div>
<hr>
<div class="refsect2">
<a name="GSocketFamily"></a><h3>enum GSocketFamily</h3>
<pre class="programlisting">typedef enum {
  G_SOCKET_FAMILY_INVALID,
#ifdef GLIB_SYSDEF_AF_UNIX
  G_SOCKET_FAMILY_UNIX = GLIB_SYSDEF_AF_UNIX,
#endif
  G_SOCKET_FAMILY_IPV4 = GLIB_SYSDEF_AF_INET,
  G_SOCKET_FAMILY_IPV6 = GLIB_SYSDEF_AF_INET6
} GSocketFamily;
</pre>
<p>
The protocol family of a <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a>. (These values are
identical to the system defines <code class="literal">AF_INET</code>, <code class="literal">AF_INET6</code> and <code class="literal">AF_UNIX</code>,
if available.)
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="G-SOCKET-FAMILY-INVALID:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_INVALID</code></span></p></td>
<td>no address family
</td>
</tr>
<tr>
<td><p><a name="G-SOCKET-FAMILY-UNIX:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_UNIX</code></span></p></td>
<td>the UNIX domain family
</td>
</tr>
<tr>
<td><p><a name="G-SOCKET-FAMILY-IPV4:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_IPV4</code></span></p></td>
<td>the IPv4 family
</td>
</tr>
<tr>
<td><p><a name="G-SOCKET-FAMILY-IPV6:CAPS"></a><span class="term"><code class="literal">G_SOCKET_FAMILY_IPV6</code></span></p></td>
<td>the IPv6 family
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-socket-address-new-from-native"></a><h3>g_socket_address_new_from_native ()</h3>
<pre class="programlisting"><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> *       g_socket_address_new_from_native (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> native</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> len</code></em>);</pre>
<p>
Creates a <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> subclass corresponding to the native
<span class="type">struct sockaddr</span> <em class="parameter"><code>native</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>native</code></em> :</span></p></td>
<td>a pointer to a <span class="type">struct sockaddr</span>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
<td>the size of the memory location pointed to by <em class="parameter"><code>native</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a new <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> if <em class="parameter"><code>native</code></em> could successfully be converted,
otherwise <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-socket-address-get-family"></a><h3>g_socket_address_get_family ()</h3>
<pre class="programlisting"><a class="link" href="gio-GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a>       g_socket_address_get_family         (<em class="parameter"><code><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);</pre>
<p>
Gets the socket family type of <em class="parameter"><code>address</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the socket family type of <em class="parameter"><code>address</code></em>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-socket-address-to-native"></a><h3>g_socket_address_to_native ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            g_socket_address_to_native          (<em class="parameter"><code><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> dest</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> destlen</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Converts a <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> to a native <span class="type">struct
sockaddr</span>, which can be passed to low-level functions like
<code class="function">connect()</code> or <code class="function">bind()</code>.
</p>
<p>
If not enough space is availible, a <a class="link" href="gio-GIOError.html#G-IO-ERROR-NO-SPACE:CAPS"><code class="literal">G_IO_ERROR_NO_SPACE</code></a> error is
returned. If the address type is not known on the system
then a <a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-SUPPORTED:CAPS"><code class="literal">G_IO_ERROR_NOT_SUPPORTED</code></a> error is returned.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>dest</code></em> :</span></p></td>
<td>a pointer to a memory location that will contain the native
<span class="type">struct sockaddr</span>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>destlen</code></em> :</span></p></td>
<td>the size of <em class="parameter"><code>dest</code></em>. Must be at least as large as
<a class="link" href="gio-GSocketAddress.html#g-socket-address-get-native-size" title="g_socket_address_get_native_size ()"><code class="function">g_socket_address_get_native_size()</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>
<a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>dest</code></em> was filled in, <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-socket-address-get-native-size"></a><h3>g_socket_address_get_native_size ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a>              g_socket_address_get_native_size    (<em class="parameter"><code><a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>);</pre>
<p>
Gets the size of <em class="parameter"><code>address</code></em>'s native <span class="type">struct sockaddr</span>.
You can use this to allocate memory to pass to
<a class="link" href="gio-GSocketAddress.html#g-socket-address-to-native" title="g_socket_address_to_native ()"><code class="function">g_socket_address_to_native()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GSocketAddress.html#GSocketAddress" title="GSocketAddress"><span class="type">GSocketAddress</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the size of the native <span class="type">struct sockaddr</span> that
<em class="parameter"><code>address</code></em> represents</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>